﻿/********************************************************************
* Copyright (C) 2020-20XX   All Rights Reserved.
* All rights reserved.
*
* FileName：encodenormalize.h
* Details ：Check GBK character you could do
*     code >= 0x8000 && _pGbk2Utf16[code - 0x8000] != 0
*
* Author  : XX
* version : 1.0.0
* Date    : 2021/11/17 09:08:00
*********************************************************************/

#ifndef __ENCODENORMALIZE_H__
#define __ENCODENORMALIZE_H__

#ifdef __cplusplus
extern "C" {
#endif

#define ENCODE_TO_LOWER        1   // 字母转为小写
#define ENCODE_TO_UPPER        2   // 字母转为大写
#define ENCODE_TO_HALF         4   // 全角符号转为半角符号
#define ENCODE_TO_SIMPLIFIED   8   // 繁体转为简体

    // 初始化
    void encode_normalize_init();
    // 将输入的gbk字符按照 options 的要求进行归一化
    void encode_normalize_gbk(char *text, unsigned options);
    // 将输入的utf8字符按照 options 的要求进行归一化
    void encode_normalize_utf8(char *text, unsigned options);

    // 将gbk编码转为utf-8编码
    int gbk_to_utf8(const char *from, unsigned int from_len, char **to, unsigned int *to_len);
    // 将utf-8编码转为gbk编码
    int utf8_to_gbk(const char *from, unsigned int from_len, char **to, unsigned int *to_len);

#ifdef __cplusplus
}
#endif

#endif // __ENCODENORMALIZE_H__
